/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tableview;

import data.Jobrotation;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Hùng
 */
public class JobrotationTableView extends AbstractTableModel {

    List<Jobrotation> lJob;
    
    public JobrotationTableView() {
        this(new ArrayList<Jobrotation>());
    }

    public JobrotationTableView(List<Jobrotation> lJob) {
        this.lJob = lJob;
    }


    public List<Jobrotation> getlJob() {
        return lJob;
    }

    public void setlJob(List<Jobrotation> lJob) {
        this.lJob = lJob;
    }

    @Override
    public int getRowCount() {
        if(lJob != null){
            return this.lJob.size();
            
        }
        return 0; //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getColumnCount() {
        return 10;
    }

   
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object value = null;
        Jobrotation tmpJob = this.lJob.get(rowIndex);
        switch (columnIndex) {
            case 0:
                value = tmpJob.getId();
                break;
            case 1:
                value = tmpJob.getEmployees().getEmpid();
                break;
            case 2:
                value = tmpJob.getPresentdeptno();
                break;
            case 3:
                value = tmpJob.getPresentdesign();
                break;
            case 4:
                value = tmpJob.getPresentsecname();
                break;
            case 5:
                value = tmpJob.getDepartments().getDeptno();

                break;
            case 6:
                if (tmpJob.getSections() != null) {
                    value = tmpJob.getSections().getSectname();
                }
                break;
            case 7:
                value = tmpJob.getDesignation().getDesignation();
                break;
            case 8:
                value = tmpJob.getDate();
                break;
            case 9:
                 
                 value = tmpJob.getStatus();
                break;
        }
        return value;
    }
    
    @Override
    public String getColumnName(int column) {
        String value = "";
        switch (column) {
            case 0:
                value = "Id";
                break;
            case 1:
                value = "EmpId";
                break;
            case 2:
                value = "PreDeptno";
                break;
            case 3:
                value = "PreDesign";
                break;
            case 4:
                value = "PreSec";
                break;
            case 5:
                value = "DptDeptNo";
                break;
            case 6:
                value = "DptSec";
                break;
            case 7:
                value = "DptDesign";
                break;
            case 8:
                value = "Date";
                break;
            case 9:
                value = "Status";
                break;
        }
        return value;
    }
}
